<template>
  <div class="box">
    <div class="banner">
      <!-- 轮播图 -->
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item v-for="item in swiper" :key="item.id">
          <img :src="item.picUrl" alt="" class="swiper" />
        </van-swipe-item>
      </van-swipe>
      <!-- 专栏导航 -->
      <ul class="banner-nav">
        <li @click="$router.push('/sign')">
          <img src="@/assets/image/签到.png" />
          签到
        </li>
        <li @click="$router.push('/gift')">
          <img src="@/assets/image/礼券.png" />
          礼券
        </li>
        <li @click="$router.push('/bargain')">
          <img src="@/assets/image/砍价.png" />
          砍价
        </li>
        <li @click="$router.push('/choiceness')">
          <img src="@/assets/image/专栏.png" />
          专栏
        </li>
      </ul>
    </div>

    <!-- 砍价 -->
    <div class="bargain" @click="$router.push('/bargain')">
      <h3>
        <span>全民砍价</span>
        <i class="van-icon van-icon-arrow"></i>
      </h3>
      <!-- 砍价商品 -->
      <div class="bargain-shop">
        <img src="@/assets/image/shop.jpg" alt="" />
        <div class="right">
          <p>重返校园 男士连帽牛仔外套</p>
          <span>复古校园感，青春活力</span>
          <ul>
            <li>
              <span> <b>￥0.9</b> </span>
              <span class="one">低价</span>
            </li>
            <li>
              <span>￥1</span>
              <span>原价</span>
            </li>
            <li>
              <span>200件</span>
              <span>限量</span>
            </li>
          </ul>
        </div>
      </div>
    </div>

    <!-- 精选专题 -->
    <div class="choiceness">
      <h3>
        <span @click="$router.push('/choiceness')">精选专题</span>
        <i class="van-icon van-icon-arrow"></i>
      </h3>
      <!-- 图文 -->
      <ul>
        <li v-for="item in movie" :key="item.id">
          <img :src="item.pic" alt="" />
          <p>{{ item.title }}</p>
          <span>{{ item.descript }}</span>
        </li>
      </ul>
    </div>

    <!-- 人气推荐 -->
    <div class="popularity">
      <h3>
        <span @click="$router.push('/popularity')">人气推荐</span>
        <i class="van-icon van-icon-arrow"></i>
      </h3>
      <ul>
        <li v-for="item in hot" :key="item.id" @click="godetail(item)">
          <img :src="item.pic" alt="" />
          <p>{{ item.name }}</p>
          <p>
            <span>{{ item.characteristic }}</span>
          </p>
          <b> ￥{{ item.minPrice }} </b>
        </li>
      </ul>
    </div>

    <h3></h3>
  </div>
</template>

<script>
export default {
  data() {
    return {
      swiper: [],
      movie: [],
      hot: [],
    };
  },
  mounted() {
    // 轮播
    this.$http("https://api.it120.cc/small4/banner/list", "get").then((res) => {
      // console.log(res);
      this.swiper = res.data.data;
    });
    // 精选
    this.$http("https://api.it120.cc/small4/cms/news/list", "get").then(
      (res) => {
        // console.log(res);
        this.movie = res.data.data;
      }
    );
    //人气推荐
    this.$http(
      "https://api.it120.cc/small4/shop/goods/kanjia/list",
      "get"
    ).then((res) => {
      console.log(res);
      this.hot = res.data.data.goodsMap;
    });
  },
  methods: {
    // 人气推荐列表详情
    godetail(item) {
      this.$router.push({ path: "/popHomeDetail", query: { item } });
    },
  },
};
</script>

<style lang="scss" scoped>
.box {
  margin-bottom: 1.2rem; //61.41px
}
// 轮播
.banner {
  // margin-bottom: 0.3rem;
  width: 100%;
  height: 7.5rem; //375px
  position: relative;
  top: 0;
  left: 0;
  //轮播
  > .van-swipe,
  .van-swipe-item {
    width: 100%;
    height: 100%;
    .swiper {
      //图
      width: 100%;
      // height: 7.5rem;
      height: 100%;
    }
  }
  // 轮播底部
  .banner-nav {
    box-sizing: border-box;
    font-size: 0.36rem; //18
    border-radius: 20% 20% 0 0;
    background-color: #fff;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    // height: 2.3rem;  //115.36
    display: flex;
    line-height: 0.8rem; //40px
    padding-top: 0.24rem; //12
    li {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      img {
        width: 0.8rem;
      }
    }
  }
}

// 砍价
.bargain {
  font-size: 0.28rem; //14
  background-color: #fff;
  // 砍价商品
  .bargain-shop {
    box-sizing: border-box;
    width: 100%;
    height: 2.6rem; //130px
    border-top: 0.01rem solid #e9e9e9;
    padding: 0.2rem;
    img {
      height: 2.27rem;
      width: 2.27rem; //113.94
      float: left;
      border-radius: 5%;
      margin-right: 0.2rem;
    }
    .right {
      p {
        margin-bottom: 0.2rem;
      }
      span {
        font-size: 0.22rem;
        color: #ccc;
      }
      ul {
        width: 50%;
        display: flex;
        font-size: 0.25rem;
        justify-content: space-between;
        color: #ccc;
        margin-top: 0.7rem;
        li {
          display: flex;
          flex-direction: column;
          align-items: center;
          b {
            color: #d00000;
          }
          .one {
            color: #000;
          }
        }
      }
    }
  }
}

h3 {
  text-align: center;
  font-weight: 400;
  font-size: 0.3rem; //15
  height: 0.952rem; //47.92
  line-height: 0.952rem;
  background-color: #fff;
  border-top: 0.3rem solid #f5f5f5;
}

// 精选专题
.choiceness {
  background-color: #fff;
  // 图文
  > ul {
    display: flex;
    overflow-x: scroll;
    width: 100%;
    height: 5.45rem; //272.6px
    font-size: 0.26rem;
    li {
      width: 6.375rem; //318.75
      margin-left: 0.2rem;
      line-height: 0.5rem;
      img {
        width: 100%;
        height: 4.096rem; //204.8
        border-radius: 3%;
      }
      span {
        color: #a8a8a8;
        font-size: 0.24rem; //12
        display: inline-block;
        width: 75%;
        //超出文字变成...
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
}

// 人气推荐
.popularity {
  background-color: #fff;
  ul {
    font-size: 0.3rem;
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    justify-content: space-evenly;
    li {
      line-height: 0.39rem;
      width: 45%;
      height: 5.56rem; //227.94
      img {
        width: 100%;
        height: 4.33rem; //216.34
      }
      p {
        width: 90%;
        font-size: 0.28rem; //14px
        //超出文字变成...
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      span {
        font-size: 0.24rem; //12
        color: #b2b2b2;
      }
      b {
        font-size: 0.24rem; //12
        color: #d00000;
        font-weight: 400;
      }
    }
  }
}
</style>
